﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Administration/Administration.Master"
    AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="mal.balades.Web.Administration.Visits.Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style>
        .selected
        {
            background-color: Blue;
        }
        
        .isDirty
        {
            background-color: Yellow;
        }
        
        .isDeleted
        {
            background-color: gray;
        }
        
        .visitpicture
        {
        }
    </style>
    <%--    data-bind="css:{selected:IsSelected}, dblclick: Select" id="Visit-${ VisitID }"--%>
    <script id="visitsTemplate" type="text/html">    
        <tr id="${ VisitID }" data-bind="css:{isDirty:IsDirty()}" >
            <td>${ Title } </td>
             <td>
                <img src="/images/tick.png" data-bind="visible:Visible" />
                <img src="/images/cross.png" data-bind="visible:!Visible()" />
             </td>
            <td>
                <img src="/images/tick.png" data-bind="visible:SumUp" />
                <img src="/images/cross.png" data-bind="visible:!SumUp()" />
             </td>
              <td>
                <img src="/images/tick.png" data-bind="visible:Text" />
                <img src="/images/cross.png" data-bind="visible:!Text()" />
             </td>             
              <td>
                <img src="/images/tick.png" data-bind="visible:Gps" />
                <img src="/images/cross.png" data-bind="visible:!Gps()" />
             </td>
              <td>
                <img src="/images/tick.png" data-bind="visible:Pictures" />
                <img src="/images/cross.png" data-bind="visible:!Pictures()" />
             </td>
              <td>
                <img src="/images/tick.png" data-bind="visible:Informations" />
                <img src="/images/cross.png" data-bind="visible:!Informations()" />
             </td>

        </tr> 
       
    </script>
    <script id="visitTabsTemplate" type="text/html">    
        <button data-bind="click:Open">${ Title } </button>
    </script>
    <script id="visitPicturesTemplate" type="text/html">    
        <div id="picture-${PictureID}" class="visitpicture" data-bind="css:{isDeleted:IsDeleted(), isDirty:IsDirty()}">
            
            <img src="http://autourdeaix.free.fr/photos/${ Url }.jpg" 
            width="150" style="float:left" />
            
            Titre : <input data-bind="value: Title,valueUpdate: 'keyup'" style="width: 200px"
            maxlength="100" />                
            <br />
            Url : <input data-bind="value: Url,valueUpdate: 'keyup'" style="width: 200px"
            maxlength="100" />                
            <br />
           <select data-bind="options: PictureTypes
            , optionsText: 'Name', value: SelectedPictureType">
           </select>

           <br />
           <button data-bind="click:Delete">Supprimer</button>
            <div style="clear:both" ></div>
        </div>
    </script>
    <script id="visitTemplate" type="text/html">  
        
    </script>
    <span data-bind="visible:IsLoading()">Loading ... </span>
    <div data-bind="visible:!IsLoading()">
        <!--Opened tabs -->
        <button data-bind="click: function(){viewModel.SelectVisit()}">
            Tableau de bord
        </button>

        <button data-bind="click: function(){viewModel.SelectedVisit().Save()}, enable: viewModel.SelectedVisit().IsDirty()">
            Sauvegarder
        </button>

         <button data-bind="click: function(){viewModel.Save()}">
            Sauvegarder tout
        </button>
        
        <!--Search tab -->
        <div data-bind="visible:DashboardTabIsSelected">
            <!--Filters -->
            <input type="radio" id="allVisits" value="allVisits" data-bind="checked: SelectedFilterVisibility" />
            <label for="allVisits">
                Toutes les visites</label>
            <input type="radio" id="visibleVisits" value="visibleVisits" data-bind="checked: SelectedFilterVisibility" />
            <label for="visibleVisits">
                Visites visibles</label>
            <input type="radio" id="notVisibleVisits" value="notVisibleVisits" data-bind="checked: SelectedFilterVisibility" />
            <label for="notVisibleVisits">
                Visites non visibles</label>
            <!-- Dashboard -->
            <table width="100%">
                <thead>
                    <tr>
                        <td>
                            Titre :
                            <input data-bind="value: FilterText,valueUpdate: 'keyup'" />
                        </td>
                        <td>
                            Visible
                        </td>
                        <td>
                            Résumé
                        </td>
                        <td>
                            Texte
                        </td>
                        <td>
                            Gps
                        </td>
                        <td>
                            Photos
                        </td>
                        <td>
                            Inforamtions
                        </td>
                    </tr>
                </thead>
                <!--Dashnoard rows -->
                <tbody data-bind="template: {name:'visitsTemplate', foreach:VisitsToShow
                , afterAdd: viewModel.AddDoubleClickEventHandler 
                    }">
                </tbody>
            </table>
        </div>

        <!--Visit tab -->
        <div id="editvisit" data-bind="visible:SelectedVisit().IsSelected()">
            <ul>
                <li><a href="#tab-Main">Principal</a></li>
                <li><a href="#tab-Pictures">Photos</a></li>
                <li><a href="#tab-Informations">Informations</a></li>
                <li><a href="#tab-Map">Carte</a></li>
            </ul>

            <div id="tab-Main">
            <h1>Principal</h1>
                Titre :
                <input data-bind="value: SelectedVisit().Visit().Title,valueUpdate: 'keyup'" style="width: 600px"
                    maxlength="100" />
                <br />
                <label for="visitVisible">
                    Visible :</label>
                <input id="visitVisible" type="checkbox" data-bind="checked: SelectedVisit().Visit().Visible,valueUpdate: 'mouseup'" />
                <br />
                Url :
                <input data-bind="value: SelectedVisit().Visit().UrlName,valueUpdate: 'keyup'" style="width: 600px"
                    maxlength="60" />
                <br />
                
                 <input type="checkbox" data-bind="checked:SelectedVisit().SumUp" /> Résumé :
                <br />
                <textarea rows="5" cols="100" data-bind="value: SelectedVisit().Visit().SumUp">
                            </textarea>
                <br />
                <input type="checkbox" data-bind="checked:SelectedVisit().Text" /> Texte :
                <br />
                <textarea rows="20" cols="100" data-bind="value: SelectedVisit().Visit().Text">
                            </textarea>
            </div>

            <div id="tab-Pictures">
                <h1><input type="checkbox" data-bind="checked:SelectedVisit().Pictures" /> Photos</h1>
                
            
                <div id="pictures" data-bind="template: {name:'visitPicturesTemplate', foreach:SelectedVisit().Visit().PicturesToShow}">
                </div>

                <button data-bind="click:AddPicture">Nouvelle photo</button>
            </div>

            <div id="tab-Informations">
                <h1><input type="checkbox" data-bind="checked:SelectedVisit().Informations" /> Informations</h1>
                
            </div>

             <div id="tab-Map">
                 <h1><input type="checkbox" data-bind="checked:SelectedVisit().Gps" /> Carte</h1>
                 
                 Latitude :
                    <input data-bind="value: SelectedVisit().Visit().Latitude,valueUpdate: 'keyup'" style="width: 200px" />
                    Longitude :
                    <input data-bind="value: SelectedVisit().Visit().Longitude,valueUpdate: 'keyup'"
                        style="width: 200px" />
                    <br />


                   
                <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
                    width="100%" height="600 id="map">
                    <param name="source" value="/ClientBin/mal.balades.Map.xap" />
                    <param name="onError" value="onSilverlightError" />
                    <param name="background" value="white" />
                    <param name="minRuntimeVersion" value="4.0.50401.0" />
                    <param name="autoUpgrade" value="true" />
                     <param name="InitParams" value="admin=1" />
                     <param name="onLoad" value="MapLoaded"/>
                    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration: none">
                        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight"
                            style="border-style: none" />
                    </a>
                </object>
                <iframe id="_sl_historyFrame" style="visibility: hidden; height: 0px; width: 0px;
                    border: 0px"></iframe>
            
            </div>
           
        </div>
    </div>
</asp:Content>
